"""
分析：
5=5*4*3*2*1
4=4*3*2*1
3=3*2*1
2=2*1
1=1
"""

num = int(input('>>>'))
sum = 1
total = 1
for i in range(1, num + 1):
    sum = sum * i  # 求阶乘
    print(i, sum)
    total = total + sum  # 求阶乘之和
print('total', total)
